/**
 *  Document   : Manager
 *  Created on : 17 juil. 2008, 10:21:33
 *  Author     : Rivo
 */

package gla.centralhotel.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "manager")
@NamedQueries({@NamedQuery(name = "Manager.findById", query = "SELECT m FROM Manager m WHERE m.id = :id"),
@NamedQuery(name = "Manager.findByCivility", query = "SELECT m FROM Manager m WHERE m.civility = :civility"),
@NamedQuery(name = "Manager.findByName", query = "SELECT m FROM Manager m WHERE m.name = :name"),
@NamedQuery(name = "Manager.findByFirstname", query = "SELECT m FROM Manager m WHERE m.firstname = :firstname"),
@NamedQuery(name = "Manager.findByCompanyName", query = "SELECT m FROM Manager m WHERE m.companyName = :companyName"),
@NamedQuery(name = "Manager.findByAddress1", query = "SELECT m FROM Manager m WHERE m.address1 = :address1"),
@NamedQuery(name = "Manager.findByAddress2", query = "SELECT m FROM Manager m WHERE m.address2 = :address2"),
@NamedQuery(name = "Manager.findByAddress3", query = "SELECT m FROM Manager m WHERE m.address3 = :address3"),
@NamedQuery(name = "Manager.findByEmail", query = "SELECT m FROM Manager m WHERE m.email = :email"),
@NamedQuery(name = "Manager.findByPassword", query = "SELECT m FROM Manager m WHERE m.password = :password")})
public class Manager implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "civility", nullable = false)
    private String civility;
    @Column(name = "name", nullable = false)
    private String name;
    @Column(name = "firstname", nullable = false)
    private String firstname;
    @Column(name = "company_name")
    private String companyName;
    @Column(name = "address1", nullable = false)
    private String address1;
    @Column(name = "address2")
    private String address2;
    @Column(name = "address3")
    private String address3;
    @Column(name = "email", nullable = false)
    private String email;
    @Column(name = "password", nullable = false)
    private String password;
    @JoinColumn(name = "ref_country", referencedColumnName = "id")
    @ManyToOne
    private Country refCountry;
    @JoinColumn(name = "ref_zipcode", referencedColumnName = "id")
    @ManyToOne
    private Zipcode refZipcode;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refManager")
//    private Collection<Hotel> hotelCollection;

    public Manager() {
    }

    public Manager(Integer id) {
        this.id = id;
    }

    public Manager(Integer id, String civility, String name, String firstname, String address1, String email, String password) {
        this.id = id;
        this.civility = civility;
        this.name = name;
        this.firstname = firstname;
        this.address1 = address1;
        this.email = email;
        this.password = password;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCivility() {
        return civility;
    }

    public void setCivility(String civility) {
        this.civility = civility;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getAddress1() {
        return address1;
    }

    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    public String getAddress2() {
        return address2;
    }

    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    public String getAddress3() {
        return address3;
    }

    public void setAddress3(String address3) {
        this.address3 = address3;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Country getRefCountry() {
        return refCountry;
    }

    public void setRefCountry(Country refCountry) {
        this.refCountry = refCountry;
    }

    public Zipcode getRefZipcode() {
        return refZipcode;
    }

    public void setRefZipcode(Zipcode refZipcode) {
        this.refZipcode = refZipcode;
    }

//    public Collection<Hotel> getHotelCollection() {
//        return hotelCollection;
//    }
//
//    public void setHotelCollection(Collection<Hotel> hotelCollection) {
//        this.hotelCollection = hotelCollection;
//    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Manager)) {
            return false;
        }
        Manager other = (Manager) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gla.centralhotel.model.Manager[id=" + id + "]";
    }

}
